package com.fowo.api.service.handleWork;

import com.fowo.api.mapper.PayableMapper;
import com.fowo.api.model.payable.PayableNotApproveAction;
import com.fowo.api.model.payable.PayableVo;
import com.fowo.api.service.impl.PayableServiceImpl;
import com.fowo.api.user.model.JwtUserInfo;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import javax.annotation.Resource;

@Component
public class PayableNotApprove implements PayableNotApproveAction {

    @Resource
    private PayableMapper payableMapper;

    @Override
    public void run(Long id) throws Exception {
        JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
        PayableVo voById = payableMapper.selectVoById(id);
        Assert.notNull(voById,"不存在");
//        Assert.notNull(voById.getSupplierId(),"请选择供应商!");
        Assert.isTrue(voById.getStauts().equals("1"),"违规操作!");
        voById.setStauts("0");
        voById.setVerifier((long) -1);
        payableMapper.updateById(voById);
    }
}
